import headss from '../../components/header/index.vue'
import Vue from 'vue'
import BScroll from '@better-scroll/core'
import { Lazyload, Swipe, SwipeItem,Rate,Field } from 'vant'
import { Swiper, SwiperSlide } from 'vue-awesome-swiper'
Vue.use(Lazyload)
export default {
  name:'jiyang',
  data:function(){
    return {
      value: 3,
      input:"",
      swiperOption: {
        direction: 'vertical',
        slidesPerView: 'auto',
        freeMode: true,
        scrollbar: {
          el: '.swiper-scrollbar'
        },
        mousewheel: true,
        on: {
          touchEnd: function(swiper,event){
            //你的事件
            console.log('我到底了')
          },
        },
      },
      images: [
        'https://codefun-proj-user-res-1256085488.cos.ap-guangzhou.myqcloud.com/61a8af0c1f655f0011bb51f4/61c94cba1158630011a4e26c/16406704932698007257.png',
        'https://codefun-proj-user-res-1256085488.cos.ap-guangzhou.myqcloud.com/61a8af0c1f655f0011bb51f4/61c94cba1158630011a4e26c/16406704932698007257.png',
        'https://codefun-proj-user-res-1256085488.cos.ap-guangzhou.myqcloud.com/61a8af0c1f655f0011bb51f4/61c94cba1158630011a4e26c/16406704932698007257.png',
        'https://codefun-proj-user-res-1256085488.cos.ap-guangzhou.myqcloud.com/61a8af0c1f655f0011bb51f4/61c94cba1158630011a4e26c/16406704932698007257.png'
      ],	
      list:[]
    }
  },
  components: {
    [Swipe.name]: Swipe,
    [SwipeItem.name]: SwipeItem,
    [Rate.name]: Rate,
    [Field.name]:  Field,
    headss,
    Swiper,
    SwiperSlide,
  },
  mounted() {
    this.init()
    const that = this
     //监听事件
      window.onresize = ()=>{
        return(()=>{
          that.bs.refresh()
      })()
      }
  },
  beforeDestroy() {
    this.bs.destroy()
  },
  methods: {
    fa(){
      this.list.push({
          flat:'right',
          id:new Date().getTime(),
          info:this.input
      })
      this.input = ''
      this.$nextTick(() => {
        this.bs.refresh()
      })
    },
    init() {  
      this.bs = new BScroll(this.$refs.scroll, {
        probeType: 1,
        click: true
      })
      this.bs.on('scrollStart', () => {
        console.log('scrollStart-')
      })
      this.bs.on('scroll', ({ y }) => {
        console.log('scrolling-')
      })
      this.bs.on('scrollEnd', (pos) => {
        console.log(pos)
      }) 
      this.list = [{
        flat:'left',
        id:1,
        info:'您好，请详细描述您的宠物的病情（具体症状、患病时长等）'
      },
      {
        flat:'right',
        id:2,
        info:'您好，我想问下狗狗最近两天发热,精神沉郁、不食、还伴随呕吐。'
      },
      {
        flat:'left',
        id:3,
        info:'请问这次问题出现多久了？'
      },
      {
        flat:'right',
        id:4,
        info:'好的，谢谢'
      },]
    },
    goto(){
      this.$router.go(-1)
    }    
  }
}
